﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xiaov.SmartWeb.Infrastructure.ExtMethod;

namespace Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.Json
{
  public partial class ReportState : System.Web.UI.Page
  {

    protected void Page_Load(object sender, EventArgs e)
    {
      string nf = Request.QueryString["year"].ToRequestString();
      string yf = Request.QueryString["month"].ToRequestString();
      Response.Clear();
      //特殊处理 因为旬报的缘故 本月应当有三张报表
      string sql = @"select " + nf + @" as nf," + yf + @" as yf, t2.bbbm,t2.bbwh as lrbh,t2.bbmc,t2.bbzq,t2.yqsbsj,null as YSB,null WSB from (
select distinct(bbbm) from bbdytbdw t where length(dwbm)=4) t1 , code_bbbmb t2 where t1.bbbm=t2.bbbm  order by t2.pxxh
";
      DataSet ds = Maticsoft.DBUtility.DbHelperOra.Query(sql);

      foreach (DataRow dr in ds.Tables[0].Rows)
      {

        //dr["YQSBSJ"] = Xiaov.SmartWeb.Model.ActiveRecord.CODE_BBBMB.GetReportTimeStopTime(dr["YQSBSJ"].ToRequestString(), dr["nf"].ToRequestString(), dr["yf"].ToRequestString());
        dr["YSB"] = Xiaov.SmartWeb.Model.ActiveRecord.BBDYTBDW.GetDanweiHasReport(dr["nf"].ToRequestString(), dr["yf"].ToRequestString(), dr["BBBM"].ToRequestString());
        dr["WSB"] = Xiaov.SmartWeb.Model.ActiveRecord.BBDYTBDW.GetDanweiNotReport(dr["nf"].ToRequestString(), dr["yf"].ToRequestString(), dr["BBBM"].ToRequestString());

      }

      Response.Write(ds.Tables[0].ToJsonForGrid());
      Response.End();

    }


  }
}